import conf from '../conf'
import axios from 'axios';
import qs from 'qs';

const io = {
  configUrls: function () {
      this.getAllUserOrders= conf.baseApiPath +  '/api/admin/activityGroupSP/getAllUserOrders'
      this.exportOrders= conf.baseApiPath +  '/api/admin/activityGroupSP/exportOrders'
      this.refundByOrderId= conf.baseApiPath +  '/api/admin/activityGroupSP/refundByOrderId'
      this.sycnByOrderId= conf.baseApiPath +  '/api/admin/activityGroupSP/sycnByOrderId'
      this.sycnSP= conf.baseApiPath +  '/api/admin/activityGroupSP/sycnSP'
  },
  post: async function (url, data, success, fail, timeout) {
    try {
      let formdata = qs.stringify(data);
      let res = await axios({
        url: url,
        method: 'POST',
        data: formdata,
        dataType: 'json',
        timeout: timeout || 30000,
        headers: { 'MessageSn': new Date().getTime() }
      });
      if (!res.data.success && res.data.desc) {
        alert(res.data.desc)
      }
      return res;
    } catch (err) {
      console.log(err)
    }
  }}
io.configUrls()

export default io
